<?php
require_once 'Croese/Google/Chart/Encoding.php';
class Croese_Google_Chart_Encoding_Simple implements Croese_Google_Chart_Encoding
{
	
	protected $_simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	
	public function encode($data)
	{
		$chartData = array();
		for ($i = 0; $i < count($data); $i++)
		{
    		$currentValue = $data[$i];
    		if($currentValue > strlen($this->_simpleEncoding))
    		{
    			throw new Exception(printf("Uw opgegevens waarde '%s' is groter dan dat met de SimpleEncoding encode kan worden", $currentValue));
    		}
    		
    		if (!is_nan($currentValue) && $currentValue >= 0)
    		{
    			$chartData[] = substr($this->_simpleEncoding, $currentValue, 1);
    		}
      		else
      		{
      			$chartData[] = '_';
      		}
  		}
		return 'chd=s:' . implode('', $chartData);
	}

}
		


